const Question = require("../schema/question");

// 问题列表
const getlist = (keywords, size, page) => {
    return Question.find({ title: { $regex: keywords } })
        .limit(size)
        .skip(page * size);
};
// 问题详情
const detail = (id, selects = "") => {
    return Question.findById(id).select(selects);
};

// 创建问题
const create = (question) => {
    return Question.create(question);
};

// 更新问题
const update = (id, question) => {
    return Question.findByIdAndUpdate(id, question);
};

// 删除问题
const remove = (id) => {
    return Question.findByIdAndRemove(id);
};

module.exports = { getlist, detail, create, update, remove };
